package eu.irreality.dai.world.gen.strategy.monster;

import eu.irreality.dai.gameplay.actions.movement.StandardPassabilityCriterion;
import eu.irreality.dai.gameplay.entities.AliveEntity;
import eu.irreality.dai.gameplay.entities.Goblin;
import eu.irreality.dai.gameplay.entities.Orc;
import eu.irreality.dai.util.Roll;
import eu.irreality.dai.world.gen.LevelGenerator;
import eu.irreality.dai.world.level.Level;

public class SimpleMonsterGenerationStrategy implements
	MonsterGenerationStrategy
{

    @Override
    public void generateRandomMonsters(Level l, int n)
    {
	for (int i = 0; i < n; i++)
	{
	    int row = -1;
	    int col = -1;
	    do
	    {
		row = Roll.randomInt(l.getRows() - 1);
		col = Roll.randomInt(l.getCols() - 1);
	    } while (!l.get(row, col).get(0).equals(LevelGenerator.GROUND));

	    AliveEntity aliveEntity = null;
	    int race = Roll.randomInt(1);
	    switch (race)
	    {
	    case 0:
		aliveEntity = new Orc();
		break;
	    case 1:
		aliveEntity = new Goblin();
		break;
	    }
	    if (aliveEntity != null)
	    {
		aliveEntity
			.setPassabilityCriterion(new StandardPassabilityCriterion());
		aliveEntity.setProperty("monster_action", "idle", 10);
		l.addEntity(aliveEntity, row, col);
	    }
	}
    }

}
